﻿using Download;
using StockDataBase.models;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 股票数据;

namespace StockDataBase.Download
{
    public class DownDividend : DownBase
    {
        public DownDividend()
        { 
        
        }

        private const string PATH = @"http://web.ifzq.gtimg.cn/appstock/hk/HkInfo/getDividends?p={0}&c={1}&max=200";


        public void DownAll()
        {
            Utils.DB_Client.CreateTable(typeof( DividendInfo ) );


            var reslut = Utils.DB_Client.Select<StockInfo>("select * from StockInfo where stockId like 'hk%'");
            foreach(var item in reslut)
            {
                string str = string.Format(PATH,1,item.stockId.Replace("hk",""));
                string json = DownString(str);
                var json_cn = Utils.ConvertJs2Csharp(json) ;
                LogUtils.Print(json_cn );

                StreamWriter sw = new StreamWriter("test.txt");
                sw.WriteLine(json_cn);
                sw.Close();
                break;
            }


        }


    }
}
